<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    <h:head>
        <title>Test : find trades for a given Stock</title>
    </h:head>
    <h:body>
        <h:form>            

            Please select a stock from this list: 
            <h:selectOneMenu value="#{testFindingByStockController.beanTrade.stock}" converter="stockListConverter">
                <f:selectItems value="#{listsBean.stocks}"
                               var="stock"
                               itemValue="#{stock}"
                               itemLabel="#{stock.name} (#{stock.ticker})"/>
            </h:selectOneMenu>
                        
            <ui:remove>        Please enter a Stock id (from database): <h:inputText value="#{testFindingByStockController.beanStock.id}" /><br /> 
                id : <h:outputText value="#{testFindingByStockController.beanStock.id}" /><br />
                name : <h:outputText value="#{testFindingByStockController.beanStock.name}" /><br />
                ticker : <h:outputText value="#{testFindingByStockController.beanStock.ticker}" />
                <h:commandButton action="#{testFindingByStockController.findById}" />
            </ui:remove>
            <h:commandButton action="#{testFindingByStockController.findTrades}" value="Find trades" />
            <br />
            <u>Result</u><br />
            <c:choose>
                <c:when test="#{fn:length(testFindingByStockController.tradeResults) > 0}" >                
                    Found #{fn:length(testFindingByStockController.tradeResults)} trades. named:
                    <h:dataTable value="#{testFindingByStockController.tradeResults}" var="trade">
                        <h:column>
                            <h:outputText value="#{trade.name}" />
                        </h:column>
                    </h:dataTable>
                </c:when>
                <c:otherwise>
                    No trades found.
                </c:otherwise>
            </c:choose>
        </h:form>
    </h:body>
</html>

